USE maindatabase

if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tmpComeralInv]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[tmpComeralInv] (
	[idRecord] [int] IDENTITY (1, 1) NOT NULL ,
	[idPredpr] [bigint] NULL ,
	[invoicefullname] [varchar] (25) COLLATE Cyrillic_General_CI_AS NULL ,
	[datetrans] [datetime] NULL ,
	[status] [tinyint] NULL ,
	[recipientname] [varchar] (200) COLLATE Cyrillic_General_CI_AS NULL ,
	[signerfio] [varchar] (70) COLLATE Cyrillic_General_CI_AS NULL ,
	[namepredpr] [varchar] (300) COLLATE Cyrillic_General_CI_AS NULL ,
	[docnumber] [varchar] (50) COLLATE Cyrillic_General_CI_AS NULL ,
	[docdate] [datetime] NULL ,
	[ndsexcel] [decimal](18, 3) NULL ,
	[ndsspr] [decimal](18, 3) NULL ,
	[ndsinvoice] [decimal](18, 3) NULL ,
	[totalcostinv] [decimal](18, 3) NULL ,
	[totalcostvatinv] [decimal](18, 3) NULL ,
	[filial] [smallint] NULL ,
	[svplace] [varchar] (1) COLLATE Cyrillic_General_CI_AS NULL ,
	[numbuhspr] [varchar] (10) COLLATE Cyrillic_General_CI_AS NULL ,
	[numdocpart] [varchar] (50) COLLATE Cyrillic_General_CI_AS NULL ,
	[hide] [bit] NULL 
) ON [PRIMARY]

ALTER TABLE [dbo].[tmpComeralInv] WITH NOCHECK ADD 
	CONSTRAINT [PK_tmpComeralInv] PRIMARY KEY  CLUSTERED 
	(
		[idRecord]
	)  ON [PRIMARY] 

ALTER TABLE [dbo].[tmpComeralInv] ADD 
	CONSTRAINT [DF_tmpComeralInv_hide] DEFAULT (0) FOR [hide]
END


if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tmpComeralProv]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[tmpComeralProv] (
	[idRecord] [int] IDENTITY (1, 1) NOT NULL ,
	[numbuhspr] [varchar] (10) COLLATE Cyrillic_General_CI_AS NULL ,
	[datadoc] [datetime] NULL ,
	[numdoc] [varchar] (50) COLLATE Cyrillic_General_CI_AS NULL ,
	[numdocpart] [varchar] (50) COLLATE Cyrillic_General_CI_AS NULL ,
	[summ] [decimal](18, 3) NULL ,
	[globalcode] [varchar] (50) COLLATE Cyrillic_General_CI_AS NULL ,
	[filial] [smallint] NULL ,
	[NSF] [varchar] (30) COLLATE Cyrillic_General_CI_AS NULL 
) ON [PRIMARY]

ALTER TABLE [dbo].[tmpComeralProv] WITH NOCHECK ADD 
	CONSTRAINT [PK_tmpComeralProv] PRIMARY KEY  CLUSTERED 
	(
		[idRecord]
	)  ON [PRIMARY] 
END

